<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>自增自减运算符</title>
</head>

<body>
    <script>
        // 变量自增自减运算符
        var num = 1;
        num = num + 1; // ++num 可
        // ++num;
        console.log(num); // 2

        //1.前置递增运算符 ++ 写在变量前  ++变量
        var age = 19;
        ++age; // 类似于 age = age + 1;
        console.log(age);
        //先加1 后返回值
        var num2 = 10;
        console.log(++num2 + 10); //21
        //先自加，后返回值


        //2.后置递增运算符 ++ 写变量后面  变量++
        var age = 10;
        age++; // 类似于 age = age + 1;  
        console.log('age++ =' + age);
        // 1, 前置自增后后置自增如果单独使用效果是一样的
        // 2, 后置自增 ：先返回原值，后自加
        var num3 = 50;
        var num = 0.1 + 0.2;
        console.log(num == 0.3);
        console.log(num3++ + 10); // 60  
        console.log(num3); //51
        var age3 = 50;
        console.log(++age3 + 10); // 61
        console.log(age3); //51
    </script>
</body>

</html>